package com.uaf.aes.contoller;

import com.uaf.aes.annotation.AesSecurity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author cailu
 * @filename AnnotaResConterller
 * @description 注解方式加密
 * @date 2020/5/6 14:45
 */
@Controller
public class AnnotaResConterller {

	private static String PATH = "D:\\uaren\\aeskey\\aes.txt";

	@GetMapping("/indexs")
	public String indexs() {
		return "indexs";
	}

	@PostMapping("annotaSave")
	@ResponseBody
	@AesSecurity
	public String annotaSave(@RequestBody String data) throws Exception {
		System.out.println("解密:" + data);
		return "000000";
	}

	@PostMapping("annotaEncrypt")
	@ResponseBody
	@AesSecurity(inDecode = false)
	public String annotaEncrypt(@RequestBody String token) throws Exception {
		System.out.println("token:" + token);
		String data = "{" +
				"\"name\": \"测试\"," +
				"\"age\": \"18\"," +
				"\"ads\": \"我是中文\"," +
				"\"adasd\": \"我是\"" +
				"}";
		return data;
	}
}
